package com.cpi.cornpp.region.service;

import java.util.List;

import com.cpi.cornpp.common.exception.CornPPException;
import com.cpi.cornpp.region.converter.RegionConverter;
import com.cpi.cornpp.region.dao.RegionDAO;
import com.cpi.cornpp.region.exception.RegionException;

public class RegionService {
	public List list()throws RegionException{
		List regionsView = null;
		RegionDAO regionDAO = null;
		List regionsDTO = null;
		RegionConverter regionConverter = null;
		try{
			regionDAO = new RegionDAO();
			regionConverter = new RegionConverter();
			regionsDTO = regionDAO.list();
			regionsView = regionConverter.convertDTOsToViews(regionsDTO);
		}catch (RegionException regionException) {			
			throw regionException;
		}catch (Exception exception){
			RegionException regionException=null;
			exception.printStackTrace(System.out);
			regionException= new RegionException(exception , CornPPException.LAYER_SERVICE,CornPPException.ACTION_LISTS);
			throw regionException;
		}
		return regionsView;
	}
}